package com.llb666.shop.items.api.vo;

import com.llb666.shop.items.domain.entity.Category;
import lombok.Data;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 子类目Vo---三级商品分类.
 *
 * @author llb666
 */
@Data
public class SubCategoryVo {

    /**
     * 子类目Id
     */
    private Integer subId;

    /**
     * 子类目名称
     */
    private String subName;

    /**
     * 子类目类型
     */
    private String subType;

    /**
     * 父级类目Id
     */
    private Integer subFatherId;

    @Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
    public interface Converter {
        SubCategoryVo.Converter INSTANCE = Mappers.getMapper(SubCategoryVo.Converter.class);

        @Mappings({
                @Mapping(source = "id", target = "subId"),
                @Mapping(source = "name", target = "subName"),
                @Mapping(source = "type", target = "subType"),
                @Mapping(source = "fatherId", target = "subFatherId")
        })
        SubCategoryVo do2Vo(Category category);

        List<SubCategoryVo> do2VoList(List<Category> carouselList);
    }

}
